﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Arcadium.Graphics;
using Microsoft.Xna.Framework.Net;

namespace Arcadium.GameEntities.Projectiles
{
    abstract class Projectile : GameEntity
    {
        #region Properties

        private static long iddistributer;
        public long Id
        {
            get;
            private set;
        }

        public Gamer Shooter
        {
            get;
            private set;
        }

        public Vector2 Position
        {
            get; 
            set;
        }
        public abstract int Direction
        {
            get;
            set;
        }
        public float Rotation
        {
            get;
            set;
        }

        public Texture2D Texture
        {
            get; private set;
        }
        public Vector2 Origin
        {
            get; private set;
        }

        #endregion

        #region Initialization

        public Projectile(World world, NetworkGamer shooter, Vector2 position)
            : base(world)
        {
            Id = iddistributer++;
            Shooter = shooter;
            Position = position;
        }

        public void SetTexture(ProjectileType projectileType)
        {
            switch (projectileType)
            {
                case ProjectileType.StandardBullet:
                    Texture = ProjectileTextures.StandardBulletTexture;
                    Origin = ProjectileTextures.StandardBulletTextureOrigin;
                    break;
                //case ProjectileType.SmallEnemy:
                //    Texture = CharacterTextures.SmallEnemyTexture;
                //    Origin = CharacterTextures.SmallEnemyTextureOrigin;
                //    break;

                // TODO: Add more textureasignments

            }
        }

        #endregion

        #region Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            spriteBatch.Draw(Texture, View.Adjust(Position), null, 
                Color.White, Rotation, Origin, View.ScreenScale, 
                View.ToEffect(Direction), 0);
        }

        #endregion
    }
}
